<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>个人调班</title>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.4.2/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.4.2/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.4.2/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.4.2/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.4.2/themes/icon.css"/>" />
</head>

<body>
	<script type="text/javascript">
		
		
		/*删除*/
		function delRolepels(GEREN_ID) {
			$.messager.confirm('确认', '您确定要删除吗？', function(v) {
				if(v){
					$.post("to_tscheduper_delede", {
						GEREN_ID : GEREN_ID
					}, function() {
						$('#shq_shiftper_tb').datagrid('reload');
					});
				}else{
					
				}
			
			});
		}
		/*操作图标*/
		var perFormatter = function(value, row, index) {
			var wrongs="";
			var edits="";
			var dels="";
			
			<my:g id="37">edits = " <a btn='cell_btn_edits' onclick=editRoless("
					+ row.GEREN_ID + ","+row.STAIN_ID+ ",'"+row.STAIN_NAME+ "',"+row.TEAM_ID+ ",'"+row.TEAM_NAME+"')></a>";</my:g>
			<my:g id="38">dels = " <a btn='cell_btn_dels' onclick='delRolepels("
					+ row.GEREN_ID + ")'></a>";</my:g>
			return wrongs + edits + dels;
		}
		$(function() {
			
			/* 新增 */
			$(".add_pers").linkbutton({
				onClick : function() {
					$("#shq_per_div").panel({
						href : "to_core_personaladd"
					});
				}
			});
			
			/* 操作图*/
			$("#shq_shiftper_tb").datagrid({
				onLoadSuccess : function() {
					$("a[btn=cell_btn_edits]").linkbutton({
						iconCls : 'icon-edit',
						plain : true
					});
					$("a[btn=cell_btn_dels]").linkbutton({
						iconCls : 'icon-cancel',
						plain : true
					});
				}
			});
			/* 员工清单查找 */
			$('#zempid').textbox({
				icons : [ {
					iconCls : 'icon-add',
					handler : function(e) {
						$("#peraddfindall").dialog("open");
						//双击获取值
						$('#personal_shet').datagrid({onDblClickRow:function(index,row){
								var paperinsertid=row.STAIN_ID;
								var paperinsertname=row.STAIN_NAME;
								$('#zempid').textbox("setValue",paperinsertid);
								$('#empname').textbox("setValue",paperinsertname);
								//关闭窗口
								$('#peraddfindall').dialog('close');
							}
						});
					}
				}]
			});
			/* 原班组清单查找 */
			$('#teamId').textbox({
				icons : [ {
					iconCls : 'icon-add',
					handler : function(e) {
						$("#personfindalls").dialog("open");
						//双击获取值
						$('#personal_shets').datagrid({onDblClickRow:function(index,row){
								var paperinsertid=row.TEAM_ID;
								var paperinsertname=row.TEAM_NAME;
								$('#teamId').textbox("setValue",paperinsertid);
								$('#teamname').textbox("setValue",paperinsertname);
								//关闭窗口
								$('#personfindalls').dialog('close');
							}
						});
					}
				}]
			});
			/* 目标班组清单查找 */
			$('#mubiaoteamId').textbox({
				icons : [ {
					iconCls : 'icon-add',
					handler : function(e) {
						$("#personfindalls").dialog("open");
						//双击获取值
						$('#personal_shets').datagrid({onDblClickRow:function(index,row){
								var paperinsertid=row.TEAM_ID;
								var paperinsertname=row.TEAM_NAME;
								$('#mubiaoteamId').textbox("setValue",paperinsertid);
								$('#mubiaoteamname').textbox("setValue",paperinsertname);
								//关闭窗口
								$('#personfindalls').dialog('close');
							}
						});
					}
				}]
			});
		});
		/* 编辑 */
	  	function editRoless(GEREN_ID,STAIN_ID,STAIN_NAME,TEAM_ID,TEAM_NAME){
	  		$("#gempid").attr("value",GEREN_ID);
			$("#zempid").textbox("setValue",STAIN_ID);
			$("#zempname").textbox("setValue",STAIN_NAME);
			$("#mubiaoteamId").textbox("setValue",TEAM_ID);
			$("#mubiaoteamname").textbox("setValue",TEAM_NAME);
	  		$('#dd_person_update').dialog('open').dialog('center');
	  	}
		
	  //所有部门
		$('#personal_shift_combobox').combobox({    
		    url:'is_to_all_depts',    
		    valueField:'DEFIDE_ID',    
		    textField:'DEFIDE_NAME'   
		});
		$('#personal_shift_combobox').combobox({
			onSelect:function(record){
				$("#personal_shift_text").textbox("setValue","");
				var dName=record.DEFIDE_NAME;
				$("#personal_shet").datagrid({url:"is_to_dept_emp_alls?dName="+dName,method:'get'});
				
			}
		});
		
		$("#personal_shift_button").linkbutton({
			onClick:function(){
				var Setext = $("#personal_shift_text").textbox("getText");
				$('#personal_shift_combobox').combobox("setValue","");
				$("#personal_shet").datagrid({url:"is_to_all_emp_mohu?stainName="+Setext,method:'get'});
				$("#personal_shet").datagrid("reload");
			}
		});
		
		//班组模糊搜索
		$("#personal_team_mh").linkbutton({
			onClick:function(){
				$("#personal_shets").datagrid({url:"to_findallone_team_mohu?teamName="+$("#personal_team_text").textbox("getText"),method:'get'});
				$("#personal_shets").datagrid("reload");
			}
		});
		
	</script>
	<div id="shq_per_div" class="easyui-panel"
		data-options="fit:true,border:false">
	<table class="easyui-datagrid" id="shq_shiftper_tb"
		style="width: 100%"
		data-options="
				fitColumns:true,
				fit:true,
				pagination:true,     
				pageSize:5,    
				pageList: [5,10,30,40,50], 
				url:'shq_personal_findall',
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true,
				toolbar:'#toolsr'
        ">
		<thead>
			<tr>
				<th data-options="field:'GEREN_ID',width:40,align:'center'">编号</th>
				<th data-options="field:'STAIN_ID',width:40,align:'center'">员工编号</th>
				<th data-options="field:'STAIN_NAME',width:50,align:'center'">员工名称</th>
				<th data-options="field:'TEAM_ID',width:50,align:'center'">当前班组编号</th>
				<th data-options="field:'TEAM_NAME',width:50,align:'center'">当前班组名称</th>
				<th data-options="field:'m',width:50,align:'center',formatter:perFormatter">操作</th>
		</thead>
		<tbody>

		</tbody>
	</table>
	<!--工具-->
	<div id="toolsr" style="padding-left: 30px;">
		<my:g id="36"><a class="easyui-linkbutton add_pers"
			data-options="iconCls:'icon-add'">新增</a></my:g>
			<input class="easyui-searchbox" data-options="label:'搜索文本', width:200,labelWidth:75,       
			 	searcher:function(value,name){
      			 $('#shq_shiftper_tb').datagrid('load','shq_personal_findall_id?key='+value);      
			 }"/> 
	</div>
	</div>
	
	<!--编辑-->
	<div id="dd_person_update" class="easyui-dialog" title="编辑"
		data-options="
         width:420,
         height:200,
	     resizable:false,
	     modal:true,
	     closed:true,
	     buttons:[{
				text:'编辑',
				width:60,
				handler:function(){
					$('#tran_update_shift').form({
						onSubmit:function(params){
								return $(this).form('validate');
						},
					success:function(v){
							v = eval('('+v +')');
							if(v.success){
								$.messager.alert('恭喜', '编辑成功');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						$.messager.progress('close');// 如果提交成功则隐藏进度条
						$('#shq_shiftper_tb').datagrid('reload');
						$('#dd_person_update').dialog('close');
						}
					}).submit();
				}
				},{
				text:'取消',
				width:60,	
				handler:function(){
					$('#dd_person_update').dialog('close');
				}
			}]
        ">
		<div style="margin-left: 11%; margin-top: 10px;">
			<form action="shq_tran_personal_updates" id="tran_update_shift"
				style="text-align: right;">
				<table>
					<tbody>
						<tr>
							<td><input type="hidden" id="gempid" name="GEREN_ID"
								data-options="label:'*调班编号', width:150,labelWidth:50" /></td>
							
						</tr>
						<tr>
							<td><input class="easyui-textbox" id="zempid" name="STAIN_ID"
								data-options="label:'*员工', width:150,labelWidth:50" /></td>
							<td><input class="easyui-textbox" id="zempname" name="STAIN_NAME"
								data-options="width:150" /></td>
						</tr>
						<tr>
							<td><input class="easyui-textbox" id="mubiaoteamId"name="TEAM_ID"
								data-options="label:'*班组', width:150,labelWidth:50" /></td>
							<td><input class="easyui-textbox" id="mubiaoteamname" name="TEAM_NAME"
								data-options="width:150" /></td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
		<!--清单查找-->
			<div id="peraddfindall" class="easyui-dialog"
				data-options="
				width:450,
				title:'清单查找-考勤员工',
				bodyCls:'awby',
				modal:true,
				closed:true,
				buttons:[{
				text:'关闭',
				iconCls:'icon-cancel',
				handler:function(){
					$('#peraddfindall').dialog('close');
				}
			}]">
				<div>
					<form action="">
						<table id="list_lookup">
							
							<tr>
								<td><input id="personal_shift_text" class="easyui-textbox"
									data-options="label:'名称', width:200,labelWidth:60" /></td>
									<td>&nbsp;&nbsp;&nbsp;<a id="personal_shift_button" class="easyui-linkbutton">模糊查询</a></td>
							</tr>
							<tr>
								<td><input id="personal_shift_combobox" class="easyui-combobox"
									data-options="label:'部门', width:200,labelWidth:60,panelHeight:'auto'" /></td>
							</tr>

						</table>
					</form>
				</div>
				<table class="easyui-datagrid" id="personal_shet"
					data-options="   
				method:'post',
				pagination:true,     
				pageSize:5,   
				url:'is_to_all_staffanddept',  
				pageList: [5,10,15,20,25], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true
				">
					<thead>
						<tr>
							<th data-options="field:'STAIN_ID',width:90,align:'center'">员工编号</th>
							<th data-options="field:'STAIN_NAME',width:130,align:'center'">员工名称</th>
							<th data-options="field:'DEFIDE_NAME',width:140,align:'center'">部门</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
		<!--班组清单查找-->
			<div id="personfindalls" class="easyui-dialog"
				data-options="
				width:450,
				title:'清单查找-考勤员工',
				bodyCls:'awby',
				modal:true,
				closed:true,
				buttons:[{
				text:'关闭',
				iconCls:'icon-cancel',
				handler:function(){
					$('#personfindalls').dialog('close');
				}
			}]">
				<div>
					<form action="">
						<table id="list_lookup">
							<tr>
								<td><input id="personal_team_text" class="easyui-textbox"
									data-options="label:'班组名称', width:200,labelWidth:70" /></td>
									<td>&nbsp;&nbsp;&nbsp;<a id="personal_team_mh" class="easyui-linkbutton">模糊查询</a></td>
							</tr>
						</table>
					</form>
				</div>
				<table class="easyui-datagrid" id="personal_shets"
					data-options="   
				method:'post',
				pagination:true,     
				pageSize:5,   
				url:'to_findallone_team',  
				pageList: [5,10,15,20,25], 
				rownumbers:true,
				Striped:true, 
				singleSelect:true,
				striped:true
				">
					<thead>
						<tr>
							<th data-options="field:'TEAM_ID',width:100,align:'center'">班组编号</th>
							<th data-options="field:'TEAM_NAME',width:200,align:'center'">班组名称</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
</html>